package com.example.Windturbine.Service.Impl;

import com.example.Windturbine.Dao.LCAResultDOMapper;
import com.example.Windturbine.Error.BusinessException;
import com.example.Windturbine.Error.EmBusinessError;
import com.example.Windturbine.Service.LCAResultService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @Author 丁永新
 * @Date 2021/12/22
 */
@Service
public class LCAResultServiceImpl implements LCAResultService {

    @Resource
    LCAResultDOMapper lcaResultDOMapper;

    @Override
    @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, rollbackFor = Exception.class)
    public void deleteById(Integer id) throws BusinessException {
        try{
            Integer num= lcaResultDOMapper.deleteByPrimaryKey(id);
            if(num==0){
                throw new BusinessException(EmBusinessError.UNKNOWN_ERROR,"删除中间计算结果出错！");
            }
        }catch (Exception e){
            throw new BusinessException(EmBusinessError.UNKNOWN_ERROR,"删除中间计算结果出错！");
        }

    }
}
